home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / prog_c / lsdoor09.zip / UTIL.H < prev    next >
Text File  |  1996-04-12  |  5KB  |  115 lines

  1. #ifndef __UTIL_HEADER_FILE__
  2. #define __UTIL_HEADER_FILE__
  3.  
  4. #ifdef _DOOR_CODE_
  5. char *errorModule( void );   // Should return program ex: LsWall or LaserLink
  6.                  // (Data must be constant throughout program)
  7. #endif
  8.                  // Buffer only, no logic use by error()
  9. global char errbuf[ 80 ];    // Used to formulate "error()" calls
  10.  
  11. global char sub[ 50 ][ 40 ]; // Replacements for @oo codes
  12.  
  13. global char substring[ 120 ];// Return value of get_substring()...
  14.  
  15. global char LSLogFile[ 80 ]; // The current activity log filename...
  16.  
  17.   // Open file with automatic lock-retry...
  18.  
  19.   // fatal = (0) Return -1 on error, (1) Error if File Not Found/Other
  20.  
  21.   // ex:  open_file( fatal, "FName.ABC", O_RDONLY, SH_DENYNONE );
  22.  
  23. int open_file( int fatal, const char *name, int access, int lock );
  24.  
  25. char updated( char *fname, struct date *newerdate, struct time *newertime );
  26. char updated( struct ffblk *ff, struct date *newerdate, struct time *newertime );
  27.  
  28. void dvticks( ulong ticks ); // Delays for near 'ticks' ticks (18.2 per second)
  29. inline void dvsleep( short secs ){ dvticks( 18 * secs ); }
  30. void wait( unsigned short seconds );
  31.  
  32. int  disp_file( const char *, int=0 );    // Display file (searches paths)
  33. int  type_file( const char *, int=0 );    // Display file (Sets extension)
  34.  
  35. char *kill_codes( char *sout, char *sin );  // Removes @x and @x@ codes
  36. char *kill_disp_codes( char *sout, const char *sin );  // Removes @x codes
  37. char *set_ext( char *sout, char *sin, char *ext ); // Set extension of sin
  38. char *set_ext( char *s, char *ext );               // Set extension of s
  39. char *kill_drive( char *s );                // Removes drive letter and colon
  40. char *kill_path( char *s );                 // Remove everything before \
  41. char *kill_slash( char *s );                // Removes trailing backslash
  42. int   count_disp_bytes( const char *s ); // Returns the # of bytes in @x's
  43.  
  44. int  show_locked( char * );    // Pass filename for error-logs
  45. void show_unlocked( void );
  46.  
  47. void error( char * );
  48.  
  49. void repair( int param );  // Invokes Upgrade.Exe with itoa(param)...
  50.  
  51. char *get_size( ulong filesize, char *t );// set t =  xxxx Megs/KBytes/Bytes
  52. int  wildmatch( char *, char * ); // strcmpi() with * and ? recongnition
  53.  
  54. void detect_terminal( void );   // Try to detect Ansi/Ripterm/LTerm
  55.  
  56. int  years_since( struct date * );      // Return years since said-date
  57. unsigned long date2int( struct date * );// Returns days since 1-1-1990
  58. void int2date( struct date *, ulong );  // Fills date with days in ulong
  59. void smooth_date( struct date * );      // Moves days>30ish as a new month
  60.                     // and month>12 into new years etc.
  61. void smooth_time( struct time * );      // Moves min>60 into hour++ etc.
  62. char *format_time( struct time *, char * ); // Formats time with am/pm
  63. void string2date( char *str, struct date *dt );  // Ascii to Date{} convert
  64. unsigned int twodigit( int n );         // Returns 19xx as xx (1963 = 63)
  65. unsigned int fourdigit( int n, int thisyear );   // Rets xx as 19xx
  66.  
  67.   // Extracts a block from a "comma-based" string.  Illustration:
  68.   //         "[Substring0],[Substring1],[Substring2]"
  69. char *get_substring( char *mainstring, int subnumber, int maxlen=80 );
  70.  
  71.   // Searches for a entry in a "comma-based" string.  Like strcmpi()
  72. uchar is_substring( char *liststring, char *search, int maxlen/*=80*/ );
  73.  
  74.     // Templates:
  75.     //   0..  Anything less than SP goes splat...
  76.     //   1..  Anything other than A-Z, a-z, and space go splat...
  77. void filter( char *string, int maxlen, int style );
  78.  
  79. int  open_records( void );  // Opens Records.Dat for RdWr|Binary|Create|Apnd
  80.  
  81. void compare_records( void );   // Compares master.today with master.records
  82.  
  83. void add_log( const char * );     // Adds a line to the current activity log
  84.  
  85. void hang_up( void );
  86.  
  87. #ifndef TRIAL
  88. void spawn( char *, char * ); // a = temp_directory,
  89.        // b = program name (Batch files with or without extension are ok)
  90. #endif
  91.  
  92. void new_security( void );   // Call after online security change...
  93. int  search_user( char *, int, char );     // int = (0) Handle, (1) Real
  94.  
  95. #define show_prompt(P) if( load_prompt(P) ) display(prompt.text);
  96.  
  97. #ifndef _DOOR_MODE_
  98. #ifndef TRIAL
  99. void LaserLink( uchar *commandLine ); // Send commandLine: "Laser.Exe Han.."
  100. #endif
  101. #endif
  102.  
  103.   // Door authors - DO NOT touch the following variables.  They are reserved
  104.   // for some of the LightSpeed companions such as MAINT and LSFIX.
  105. #ifdef UtilModule
  106. char Override_Locking = false;
  107. #else
  108. extern char Override_Locking;   // Used by companions only for file access
  109. #endif
  110.  
  111. #endif
  112.  
  113. // End of Util.H
  114.  
  115.